# -*-coding:utf-8-*-
import asyncio
import threading


@asyncio.coroutine
def hello():
    print("Hello Word!:{}".format(threading.currentThread()))
    r = yield from asyncio.sleep(2)
    print('Hello Again:{}'.format(threading.currentThread()))


loop = asyncio.get_event_loop()
tasks = [hello(), hello()]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()


async def hellos():
    print("Hello Word!:{}".format(threading.currentThread()))
    await asyncio.sleep(1)
    print('Hello Again:{}'.format(threading.currentThread()))


def runeventloop():
    loop = asyncio.new_event_loop()
    tasks = [hellos(), hello()]
    loop.run_until_complete(asyncio.wait(tasks))
    loop.close()


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    runeventloop()
    asyncio.set_event_loop(loop)
